package com.xt.purchasingsystem.controller.productionManagement;

import com.xt.purchasingsystem.dto.InternalDto;
import com.xt.purchasingsystem.dto.SubmitRegisterDto;
import com.xt.purchasingsystem.service.productionManagementService.InternalpromanagementService;
import com.xt.purchasingsystem.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 生产管理--内部生产管理接口
 */
@RestController
@RequestMapping(value = "/InternalpromanagementController")
public class InternalpromanagementController {
    @Autowired
    private InternalpromanagementService internalpromanagementService;

    /**
     * 分页查询生产的接口
     *
     * @param internalDto
     * @return
     */
    @PostMapping("/getAllMManufacture")
    public Result getAllMManufacture(@RequestBody InternalDto internalDto) {
        return internalpromanagementService.getAllMManufacture(internalDto);
    }

    /**
     * 分页查询未审核生产的接口
     *
     * @param internalDto
     * @return
     */
    @PostMapping("/getAllCheckNoMManufacture")
    public Result getAllCheckNoMManufacture(@RequestBody InternalDto internalDto) {
        return internalpromanagementService.getAllCheckNoMManufacture(internalDto);
    }

    /**
     * 审核成功
     *
     * @param productId
     * @return
     */
    @PutMapping("/updateCheckTag/{productId}")
    public Result updateCheckTag(@PathVariable("productId") String productId) {
        return internalpromanagementService.updateCheckTag(productId);
    }

    //分页获取可以生产登记和的派工单
    @GetMapping("/queryAllproductionRegistrationByPage/{currNo}/{pageSize}")
    public Result queryAllproductionRegistrationByPage(@PathVariable Integer currNo, @PathVariable Integer pageSize) {
        return internalpromanagementService.queryAllproductionRegistrationByPage(currNo, pageSize);
    }

    //根据生产总表编号获取此生产的所有生产工序及工序物料
    @GetMapping("/getAllMProcedureVoAndModuleVosById/{id}/{type}")
    public Result getAllMProcedureAndModulesById(@PathVariable Integer id, @PathVariable String type) {
        return internalpromanagementService.getAllMProcedureAndModulesById(id, type);
    }

    //提交登记的接口
    @PostMapping("/submitRegister")
    public Result submitRegister(@RequestBody SubmitRegisterDto submitRegisterDto) {
        return internalpromanagementService.submitRegister(submitRegisterDto);
    }

    //分页获取所有未复核的生产派工单
    @GetMapping("/queryAllNotCheckProductionRegistrationByPage/{currNo}/{pageSize}")
    public Result queryAllNotCheckProductionRegistrationByPage(@PathVariable Integer currNo, @PathVariable Integer pageSize) {
        return internalpromanagementService.queryAllNotCheckProductionRegistrationByPage(currNo, pageSize);
    }

    //登记审核的接口
    @PostMapping("/check")
    public Result check(@RequestBody SubmitRegisterDto submitRegisterDto) {
        return internalpromanagementService.check(submitRegisterDto);
    }

    //登记交接的接口
    @PutMapping("/transferRegister/{mmanufactureId}/{mProcedureId}/{realAmount}")
    public Result transferRegister(@PathVariable Integer mmanufactureId, @PathVariable Integer mProcedureId, @PathVariable Double realAmount) {
        return internalpromanagementService.transferRegister(mmanufactureId, mProcedureId, realAmount);
    }

    //获取此工序投产数量，合格数量的方法
    @GetMapping("/getRealAmount/{mProcedureId}")
    public Result getRealAmount(@PathVariable Integer mProcedureId) {
        return internalpromanagementService.getRealAmount(mProcedureId);
    }

    //登记交接复核的接口
    @PutMapping("/transferAudit/{mmanufactureId}/{mProcedureId}/{realAmount}")
    public Result transferAudit(@PathVariable Integer mmanufactureId, @PathVariable Integer mProcedureId, @PathVariable Double realAmount) {
        return internalpromanagementService.transferAudit(mmanufactureId, mProcedureId, realAmount);
    }



}
